/* TimeStepAlgorithm.h
 *
 *	Copyright (C) 2008 CRIMERE
 *	Copyright (C) 2008 Jean-Marc Mercier
 *	
 *	This file is part of OTS (optimally transported schemes), an open-source library
 *	dedicated to scientific computing. http://code.google.com/p/optimally-transported-schemes/
 *
 *	CRIMERE makes no representations about the suitability of this
 *	software for any purpose. It is provided "as is" without express or
 *	implied warranty.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 */

#if !defined(_TimeStepAlgorithm_)
#define _TimeStepAlgorithm_
#include <src/data/Operators.h>
/* \brief base class for all one time step algorithm.

	One time step algorithm 
*/
template <class T >
struct TimeStepAlgorithm : public state_variable_traits<typename T::state_variable_type>
{
public :
//! definition of the time operator type
	typedef typename T												time_operator_type;
	typedef typename time_operator_type::indice_type				indice_type;
	typedef typename time_operator_type::state_variable_type		state_variable_type;
	typedef typename time_operator_type::result_type				result_type;
	typedef typename time_operator_type::argument_type				argument_type;
	typedef typename time_operator_type::time_type					time_type;
	void set_operator(const time_operator_type & from) {Op_ = from;};
	TimeStepAlgorithm(const time_operator_type & Op) : Op_(Op){};
	virtual ~TimeStepAlgorithm(){};
	TimeStepAlgorithm(){};
	//!accessor of Op_
	time_operator_type & get_operator() {return Op_;};
	//!const accessor of Op_
	const time_operator_type & get_operator() const {return Op_;};

protected :
	virtual void update(){
		Op_.set_state_variable(get_state_variable());
	}; 
	//!store a time operator
	time_operator_type Op_;
};

#endif
